package com.itheima.mapper;


import com.itheima.annotation.AutoFill;
import com.itheima.entity.SysMenu;
import com.itheima.entity.SysUser;
import com.itheima.enumeration.OperationType;
import com.itheima.vo.YddUserVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SysUserMapper {

    /**
     * 根据用户名查询用户
     * @param loginName
     * @return
     */
    @Select("select * from sys_user where login_name = #{loginName}")
    SysUser selectByUserName(String loginName);

    /**
     * 根据id修改用户信息
     * @param sysUser
     */
    void updateById(SysUser sysUser);

    /**
     * 根据id查询sys_user
     * @param loginUserId
     * @return
     */
    @Select("select * from sys_user where id = #{loginUserId}")
    SysUser selectById(String loginUserId);

    /**
     * 根据roleId集合查询roleName
     * @param roleIds
     * @return
     */
    List<String> selectByRoleId(List<String> roleIds);

    /**
     * 根据roleIds查询
     * @param roleIds
     * @return
     */
    List<SysMenu> selectByRoleIds(List<String> roleIds);

    /**
     * 管理员模糊查询
     * @param loginName
     * @param status
     * @param phone
     * @return
     */
    List<SysUser> selectByLoginInfo(String loginName, Integer status, String phone);

    /**
     * 通过roleIds查找角色名(roleNames)
     * @param roleIds
     * @return
     */
    List<String> selectNameByRoleIds(List<String> roleIds);

    /**
     * 管理员添加
     * @param sysUser
     */
    @AutoFill(OperationType.INSERT)
    void insert(SysUser sysUser);

    /**
     * 管理员修改
     * @param sysUser
     */
    @AutoFill(OperationType.UPDATE)
    void update(SysUser sysUser);

    /**
     * 管理员删除
     * @param id
     */
    @Delete("delete from sys_user where id = #{id}")
    void delete(String id);
}
